package bearworker.zxl.config;

import bearworker.zxl.entity.StaticDataEntity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import javax.annotation.Resource;

/**
 * Created by 逍遥的熊 on 2018/1/7.
 */

@Configuration
@PropertySource(value = { "classpath:${pro.env}/staticdata.properties" })
public class StaticDataConfig {

    @Resource
    private Environment environment;

    @Bean(name = "staticData")
    public StaticDataEntity staticData(){
        StaticDataEntity dataEntity = new StaticDataEntity();
        dataEntity.setWxToken(environment.getRequiredProperty("staticData.wxToken"));
        dataEntity.setAppId(environment.getRequiredProperty("staticData.appid"));
        dataEntity.setSecret(environment.getRequiredProperty("staticData.secret"));
        dataEntity.setPayKey(environment.getRequiredProperty("staticData.paykey"));
        dataEntity.setMchId(environment.getRequiredProperty("staticData.mchid"));
        dataEntity.setNotifyUrl(environment.getRequiredProperty("staticData.notify_url"));
        dataEntity.setAuthUrl(environment.getRequiredProperty("staticData.auth_url"));
        dataEntity.setWxReqUrl(environment.getRequiredProperty("staticData.wx_req_url"));
        dataEntity.setProAppId(environment.getRequiredProperty("staticData.pro_app_id"));
        dataEntity.setProAppSecret(environment.getRequiredProperty("staticData.pro_app_secret"));
        dataEntity.setProNotifyUrl(environment.getRequiredProperty("staticData.pro_notify_url"));
        return dataEntity;
    }
}
